<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">请假天数</label>
                    <div class="layui-input-block">
                        <input type="text" name="day" lay-verify="number" autocomplete="off" placeholder="请输入请假天数"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">请求理由</label>
                    <div class="layui-input-block">
                        <input type="text" name="leaveReason" lay-verify="title" autocomplete="off"
                               placeholder="请输入请假理由"
                               class="layui-textarea">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'easyAdmin'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let easyAdmin = layui.easyAdmin;
        form.on('submit(user-save)', function (data) {
            easyAdmin.http({
                url: '/flow/startAndExecute?name=leave&version=2',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg,
                            {
                                icon: 1,
                                time: 1000,
                                area: ['100px', '80px'],
                                content: "新增成功"
                            }
                            , function () {
                            });
                    } else {
                        layer.msg(result.msg,
                            {icon: 2, time: 1000, area: ['100px', '80px']}
                        );
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>